package com.cloud.bc.service.impl;

import com.cloud.bc.model.entity.BcAuthentications;
import com.cloud.bc.mapper.BcAuthenticationsMapper;
import com.cloud.bc.service.BcAuthenticationsService;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Service;

import java.math.BigInteger;
import java.util.List;

/**
 * 身份认证
 *
 * @author douhaichao code generator
 * @date 2021-01-06 11:45:53
 */
@Service
@AllArgsConstructor
public class BcAuthenticationsServiceImpl extends ServiceImpl<BcAuthenticationsMapper, BcAuthentications> implements BcAuthenticationsService {

    /**
   * 根据对象属性查找满足条件的第一条数据     *      * @return
   */
    @Override
    public BcAuthentications selectOne(BcAuthentications req) {
        QueryWrapper queryWrapper = new QueryWrapper<BcAuthentications>();
        queryWrapper.setEntity(req);
        return baseMapper.selectOne(queryWrapper);
    }

    /**
     * 根据条件查询所有
     */
    @Override
    public List<BcAuthentications> selectAll(BcAuthentications req) {
        QueryWrapper queryWrapper = new QueryWrapper();
        queryWrapper.setEntity(req);
        return baseMapper.selectList(queryWrapper);
    }

    /**
     * 根据对象查询所有分页数据(精确查询)     *      * @return
     */
    @Override
    public IPage<BcAuthentications> selectPage(Page page, BcAuthentications req) {
        IPage<BcAuthentications> list = baseMapper.selectPage(
                page,
                new QueryWrapper<BcAuthentications>().setEntity(req));
        return list;
    }

    /**
     * 根据对象查询所有分页数据(模糊查询)     *      * @return
     */
    @Override
    public IPage<BcAuthentications> selectPageByLike(Page page, BcAuthentications req) {
        QueryWrapper queryWrapper = new QueryWrapper();
        
                                        if (null !=req.getUserId()) {
                    queryWrapper.eq("user_id" , req.getUserId());
                }
                    
                            if (!StrUtil.isEmpty(req.getName())) {
                    queryWrapper.like("name" , req.getName());
                }
                                
                            if (!StrUtil.isEmpty(req.getIdCardNo())) {
                    queryWrapper.like("id_card_no" , req.getIdCardNo());
                }
                                
                            if (!StrUtil.isEmpty(req.getFacePhoto())) {
                    queryWrapper.like("face_photo" , req.getFacePhoto());
                }
                                
                            if (!StrUtil.isEmpty(req.getProfilePhoto())) {
                    queryWrapper.like("profile_photo" , req.getProfilePhoto());
                }
                                
                            if (!StrUtil.isEmpty(req.getIdCardPositivePhoto())) {
                    queryWrapper.like("id_card_positive_photo" , req.getIdCardPositivePhoto());
                }
                                
                            if (!StrUtil.isEmpty(req.getIdCardBackPhoto())) {
                    queryWrapper.like("id_card_back_photo" , req.getIdCardBackPhoto());
                }
                                
                                        if (null !=req.getIdentityCheck()) {
                    queryWrapper.eq("identity_check" , req.getIdentityCheck());
                }
                    
                                        if (null !=req.getIdentityCreateTime()) {
                    queryWrapper.eq("identity_create_time" , req.getIdentityCreateTime());
                }
                    
                            if (!StrUtil.isEmpty(req.getEducationPic())) {
                    queryWrapper.like("education_pic" , req.getEducationPic());
                }
                                
                                        if (null !=req.getEducationCheck()) {
                    queryWrapper.eq("education_check" , req.getEducationCheck());
                }
                    
                                        if (null !=req.getEducationCreateTime()) {
                    queryWrapper.eq("education_create_time" , req.getEducationCreateTime());
                }
                    
                            if (!StrUtil.isEmpty(req.getWorkPic())) {
                    queryWrapper.like("work_pic" , req.getWorkPic());
                }
                                
                                        if (null !=req.getWorkCheck()) {
                    queryWrapper.eq("work_check" , req.getWorkCheck());
                }
                    
                                        if (null !=req.getWorkCreateTime()) {
                    queryWrapper.eq("work_create_time" , req.getWorkCreateTime());
                }
                    
                            if (!StrUtil.isEmpty(req.getHausePic())) {
                    queryWrapper.like("hause_pic" , req.getHausePic());
                }
                                
                                        if (null !=req.getHauseCheck()) {
                    queryWrapper.eq("hause_check" , req.getHauseCheck());
                }
                    
                                        if (null !=req.getHauseCreateTime()) {
                    queryWrapper.eq("hause_create_time" , req.getHauseCreateTime());
                }
                    
                            if (!StrUtil.isEmpty(req.getCarPic())) {
                    queryWrapper.like("car_pic" , req.getCarPic());
                }
                                
                                        if (null !=req.getCarCheck()) {
                    queryWrapper.eq("car_check" , req.getCarCheck());
                }
                    
                                        if (null !=req.getCarCreateTime()) {
                    queryWrapper.eq("car_create_time" , req.getCarCreateTime());
                }
                    
                                        if (null !=req.getSesame()) {
                    queryWrapper.eq("sesame" , req.getSesame());
                }
                    
                                        if (null !=req.getFaceRecognition()) {
                    queryWrapper.eq("face_recognition" , req.getFaceRecognition());
                }
                    
                                        if (null !=req.getCreateTime()) {
                    queryWrapper.eq("create_time" , req.getCreateTime());
                }
                    
                                        if (null !=req.getMotifyTime()) {
                    queryWrapper.eq("motify_time" , req.getMotifyTime());
                }
                            IPage<BcAuthentications> list = baseMapper.selectPage(page, queryWrapper);
        return list;
    }

    /**
     * 根据条件统计数据量     *      * @return
     */
    @Override
    public int count(BcAuthentications req) {
        QueryWrapper queryWrapper = new QueryWrapper();
        queryWrapper.setEntity(req);
        return baseMapper.selectCount(queryWrapper);
    }
}
